//
//  TCChartCell.m
//  EFBTerminalCharts
//
//  Created by xiu-imac on 13-11-18.
//  Copyright (c) 2013年 adcc. All rights reserved.
//

#import "TCChartCell.h"

@implementation TCChartCell



- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _favorateButton = [UIButton buttonWithType:UIButtonTypeCustom];
		[_favorateButton setFrame:CGRectMake(0, 10, 40, 40)];
		[_favorateButton setContentMode:UIViewContentModeCenter];
		[_favorateButton setImage:[UIImage imageNamed:@"star"] forState:UIControlStateSelected];
		[_favorateButton setImage:[UIImage imageNamed:@"star gray"] forState:UIControlStateNormal];
		[_favorateButton addTarget:self action:@selector(favorateButtonTapped:) forControlEvents:UIControlEventTouchUpInside];

		_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, 10, self.frame.size.width-45, 20)];
		[_nameLabel setTextColor:[UIColor blackColor]];
		
		_pageLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, 30, self.frame.size.width-45, 20)];
		[_pageLabel setTextColor:[UIColor blackColor]];
		[_pageLabel setFont:[UIFont systemFontOfSize:12]];
		
		UIView *selectedView = [[[UIView alloc]initWithFrame:self.frame] autorelease];
		[selectedView setBackgroundColor:[UIColor colorWithRed:72/255.0 green:164/255.0 blue:197/255.0 alpha:1.0]];
		[self setSelectedBackgroundView:selectedView];
        
		[self addSubview:_favorateButton];
		[self addSubview:_nameLabel];
		[self addSubview:_pageLabel];
    }
    return self;
}

-(IBAction)favorateButtonTapped:(id)sender
{
	[((UIButton *)sender) setSelected:![((UIButton *)sender) isSelected]];
	[[NSNotificationCenter defaultCenter] postNotificationName:@"kFavorateButtonTapped" object:self];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:@"kFavorateButtonTapped"];
    [_nameLabel release];
    [_pageLabel release];
    [super dealloc];
}
@end
